/**
 * 
 */
package by.myteam.library.command;

import java.util.List;

import by.myteam.library.bo.Book;
import by.myteam.library.storage.IStorageProvider;
import by.myteam.library.storage.StorageFactory;

/**
 * @author IstiN
 *
 */
public class ListCommand implements ICommand {

	private static final String LIST = "list";
	
	private static final String INFO = "gets list book from library";

	/* (non-Javadoc)
	 * @see by.myteam.library.command.ICommand#name()
	 */
	@Override
	public String name() {
		return LIST;
	}

	/* (non-Javadoc)
	 * @see by.myteam.library.command.ICommand#info()
	 */
	@Override
	public String info() {
		return INFO;
	}

	/* (non-Javadoc)
	 * @see by.myteam.library.command.ICommand#execute(java.lang.String)
	 */
	@Override
	public void execute(String... data) {
		//TODO will add book to library
		
		List<IStorageProvider> listStorageProviders = StorageFactory.getFactory().getListStorageProviders();
		for (IStorageProvider storage : listStorageProviders) {
			System.out.println(storage.getName() + ":");
			List<Book> listBooks = storage.getListBooks();
			for (Book book : listBooks) {
				System.out.println(book);	
			}
		}
	}

}
